package com.whately.core.base.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.convert.converter.Converter;

/**
 * 参数转换
 * trim后，
 * 前台传过的参数如果是""，则转为null
 */
@Slf4j
public class StringToPureStringConverter implements Converter<String, String> {

    @Override
    public String convert(String source) {
        try {
            if(source != null){
                source = source.trim();
                if(!"".equals(source)){
                    return source;
                }
            }
        } catch (Exception e) {
            log.error("StringToPureStringConverter error ,source {} ,error {}",source,e);
        }
        return null;
    }


}
